/*
 * File Name: StatefulComposite.java
 *------------------------------------------------------------------------------
 * Copyright 2012 NCR Corporation
 *------------------------------------------------------------------------------
 * All revision information is updated automatically from source code control
 * change records - please do not manually edit.
 *------------------------------------------------------------------------------
 *
 * $LastChangedRevision:: 1569                                     $
 * $LastChangedBy:: rb250096                                       $
 * $LastChangedDate:: 2012-02-21 00:50:19 -0500 (Tue, 21 Feb 2012) $
 */

package com.ncr.nep.dashboardcore.mvp.client;

import com.google.gwt.user.client.ui.Composite;

/**
 * {@link ViewComposite} that utilizes view states for managing transitions in
 * displayed content.
 *
 * @param <T> The type of {@link Presenter} used to manage the view
 *           {@link Composite}.
 * @param <E> Enumeration type defining view states for the {@link View}.
 * 
 * @author rb250096
 * @version $Revision: 1569 $
 */
public abstract class StatefulViewComposite<T extends Presenter<?>, E extends Enum<?>>
        extends ViewComposite<T> implements StatefulView<E> {

    //--------------------------------------------------------------------------
    //
    //  Fields
    //
    //--------------------------------------------------------------------------

    /**
     * Enumeration value representing the current display state of the
     * composite view.
     */
    protected E viewState;

    //--------------------------------------------------------------------------
    //
    //  Properties
    //
    //--------------------------------------------------------------------------

    @Override
    public E getViewState() {
        return this.viewState;
    }

    @Override
    public void setViewState(E viewState) {
        if(!viewState.equals(this.viewState)) {
            this.viewState = viewState;
            this.applyViewState(this.viewState);
        }
    }

    //--------------------------------------------------------------------------
    //
    //  Methods
    //
    //--------------------------------------------------------------------------

    @Override
    public abstract void applyViewState(E viewState);
}
